package hyj.qx.websocket.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
// 注解,添加一个无参的构造方法,防止spring 创建bean的时候, 创建失败, 导致程序异常
@NoArgsConstructor
@ApiModel("分页结果数据封装")
public class PageVo<T> {
    @ApiModelProperty("页码")
    private long pageNumber;
    @ApiModelProperty("每页大小")
    private long pageSize;
    @ApiModelProperty("总页数")
    private long totalPage;
    @ApiModelProperty("总数据条数")
    private long totalCount;
    @ApiModelProperty("查询结果")
    private List<T> records;

    public PageVo(IPage< T> pageResult) {
        this.pageNumber=pageResult.getCurrent();
        this.pageSize = pageResult.getSize();
        this.totalCount = pageResult.getPages();
        this.totalCount=pageResult.getTotal();
        this.records = pageResult.getRecords();
    }
}
